;; Example demonstrating letrec functionality

;; Factorial function using letrec
(letrec ((fact (lambda (n) 
                (if (= n 0) 
                    1 
                    (* n (fact (- n 1)))))))
  (fact 5))

;; Even/odd mutual recursion using letrec
(letrec ((even? (lambda (n) 
                  (if (= n 0) 
                      #t 
                      (odd? (- n 1)))))
         (odd? (lambda (n) 
                 (if (= n 0) 
                     #f 
                     (even? (- n 1))))))
  (even? 4))

;; Forward reference example
(letrec ((f (lambda () x))
         (x 10))
  (f))